<template>
	<view class="container">
		<view class="content">
			<view class="title">
				常见问题
			</view>
			<view class="list">
				<view class="item" v-for="(item,i) in list" :key="i">
					<collapse :title_border="false">
						<view class="c-title" slot="title" slot-scope="data">
							<view class="text one-row">
								{{item.title}}
							</view>
							<image v-if="data.data" :src="$img_path('/pagesMine/56.png')" mode="widthFix"></image>
							<image v-else :src="$img_path('/pagesMine/57.png')" mode="widthFix"></image>
						</view>
						<view class="text-content" slot="content">
							{{item.content}}
						</view>
					</collapse>
				</view>
			</view>
		</view>
		
		<view class="b-btn">
			<view class="left" @click="$refs.phone.open()">
				<image :src="$img_path('/pagesMine/58.png')" mode="widthFix"></image>
				<text>电话客服</text>
			</view>
			<button>在线客服</button>
		</view>
		
		<popupBox ref="phone" contentBG="#FFFFFF" @confirm="confirm" confirmText="呼叫">
			<view class="p-toast">
				<view class="time">
					呼叫客服（8：00-18：00）
				</view>
				<view class="num">
					{{phone}}
				</view>
			</view>
		</popupBox>
	</view>
</template>

<script>
	import { helpList, getSysConfig } from '@/utils/api/userApi.js'
	import collapse from '../../components/collapse/collapse.vue';
	import popupBox from '../../components/popup/popup.vue';
	export default {
		components:{
			collapse,
			popupBox
		},
		data() {
			return {
				page:1,
				list:[],
				
				phone:''
			};
		},
		onShow() {
			this.page = 1
			this.gethelpList()
		},
		methods:{
			async gethelpList(){
				let data = await getSysConfig({site:'sys_kefu'})
				this.phone = data.data
				helpList({
					page:this.page
				}).then(res=>{
					if(this.page==1){
						this.list = res.data
					}else{
						this.list = [...this.list,...res.data]
					}
				})
			},
			
			confirm(){
				uni.makePhoneCall({
					phoneNumber:this.phone
				})
			}
		},
		onReachBottom() {
			this.page++
			this.gethelpList()
		}
	}
</script>
<style>
	page{
		background-color: #FFFFFF;
	}
</style>
<style lang="scss" scoped>
.container{
	padding: 22rpx 22rpx 0;
	box-sizing: border-box;
	padding-bottom: calc(constant(safe-area-inset-bottom) + 138rpx);
	padding-bottom: calc(env(safe-area-inset-bottom) + 138rpx);
	.content{
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 20rpx 2rpx rgba(139,139,139,0.16);
		border-radius: 20rpx;
		padding: 0 10rpx;
		box-sizing: border-box;
		.title{
			font-weight: bold;
			font-size: 32rpx;
			color: #212121;
			line-height: 44rpx;
			padding: 22rpx 22rpx 20rpx;
			box-sizing: border-box;
		}
		.list{
			.item{
				border-top: 2rpx solid #F6F6F6;
				padding: 4rpx 0;
				.c-title{
					width: 100%;
					display: flex;
					justify-content: space-between;
					align-items: center;
					.text{
						width: calc(100% - 50rpx);
						font-weight: 900;
						font-size: 28rpx;
						color: #212121;
						line-height: 40rpx;
					}
					&>image{
						width: 29rpx;
						height: 16rpx;
					}
				}
				
				.text-content{
					padding: 0 22rpx 26rpx;
					font-weight: 400;
					font-size: 26rpx;
					color: #212121;
					line-height: 40rpx;
				}
			}
		}
	}
	
	.b-btn{
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		padding: 12rpx 22rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
		padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
		background-color: #FFFFFF;
		.left{
			display: flex;
			flex-direction: column;
			align-items: center;
			image{
				width: 55.68rpx;
				height: 55.68rpx;
			}
			text{
				font-weight: 400;
				font-size: 26rpx;
				color: #333333;
				line-height: 36rpx;
				text-align: center;
			}
		}
		button{
			width: 564rpx;
			height: 96rpx;
			background: linear-gradient( 135deg, #FFA233 0%, #FB4C4C 100%);
			border-radius: 80rpx;
			font-weight: bold;
			font-size: 36rpx;
			color: #FFFFFF;
			line-height: 96rpx;
		}
	}
}
.p-toast{
	padding: 74rpx 0 66rpx;
	.time{
		font-weight: bold;
		font-size: 36rpx;
		color: #000000;
		line-height: 50rpx;
		text-align: center;
	}
	.num{
		font-weight: bold;
		font-size: 36rpx;
		color: #000000;
		line-height: 50rpx;
		text-align: center;
		margin-top: 24rpx;
	}
}
</style>
